package cq.com.cn.dao;

import cq.com.cn.model.GoodsCardModel;
import cq.com.cn.utils.JDBCUtils;

import java.util.List;

public class GoodsCardDao {
    private static  final String INSERTINTOGOODSCARD="insert into goods_card(userId,bookId,bookImg,bookName,createTime,price,stock,status) values(?,?,?,?,now(),?,?,1);";
    private static final String QUERYGOODSCARDBYUSERID="select * from goods_card where userId=? and status=1";
    public void insertGoodsCard(int userId,String bookId,String bookImg,String bookName, double price,int stock){
        Object [] array=new Object[]{userId,bookId,bookImg,bookName,price,stock};
        JDBCUtils.operater(INSERTINTOGOODSCARD,array);
    }

    public List<GoodsCardModel> findGoodsCardByUserId(int userId){
        return JDBCUtils.findList(GoodsCardModel.class,QUERYGOODSCARDBYUSERID,userId);
    }
}
